<?php
namespace backend\logic;

use think\Db;
use external\SFTools;

class CstMstLogic {
    /**
     * 根据经销商编码和查询用户资料（带品牌编码）
     * @param   string $fccode 经销商编码
     * @return  array          数组对象数据
     */
    public function getCstMstFindBuyFccode($fccode){
        $cstMst = new \backend\model_erp\CstMst;
        $deptMst = new \backend\model_erp\DeptMst;
        $cstMstFind = $cstMst::field('fTel,fDeptId')->where('fCCode', $fccode)->find();
        if (!empty($cstMstFind)) {
            $deptMstFind = $deptMst::field('fDeptId,fDeptCode,fMkCode')->where('fDeptId', $cstMstFind['fDeptId'])->find();
            $mkCode = '';
            if (!empty($deptMstFind)) {
                $mkCode = $deptMstFind['fMkCode'];
            }
            $cstMstFind['mkCode'] = $mkCode;
        }
        
        return $cstMstFind;
    }
    
}